<template>
 
  <div class="cartbox">	
		<div class="cart_nav"  @click="listshow(numbers)">
			<i class="number" v-if="numbers>0">{{numbers}}</i>
			<i class="iconfont icon-gouwuchekong"></i>
		</div>			
		<i class="sanjiao iconfont icon-up" v-if="cartlistshow"></i>
		<div class="cartlistbox" v-if="cartlistshow">
			<div class="title" v-if="!!numbers"><i>已选餐品</i><b @touchstart="remove" @click="cartfoods=[],numbers=0">清空全部</b></div>
			<ul class="carlist" v-if="numbers>0">
				<li v-for="(cartfood,index) in cartfoods">
					<i class="food_name">{{cartfood.cpmc}}</i>
					<div class="btnbox">
						<!--<i class="iconfont icon-jian subtract" @touchstart="cartfood.buynumber--,numbers--,totalprice-=cartfood.cpjg" @click="subtract(index,cartfood,totalprice,numbers)"></i>-->					
						<i class="iconfont icon-jian subtract" @click="subtract(cartfood)"></i>					
						<i class="food_numder">{{cartfood.ydfs}}</i>
						<i class="iconfont icon-jia add" @click="add(cartfood)"></i>
					</div>
					<i class="food_price">当前价￥{{cartfood.cpjg}}</i>
					
				</li>
			</ul>
		</div>			
		<div class="cart_bottom" v-if="goorderzt>0&numbers>0">
			<i class="bg"></i>
			<h4 class="total_price">共计￥{{totalprice}}</h4>
			<router-link to="/order" class="go_order">确认订单</router-link>				
		</div>
		<i class="cartnavbottom" v-else></i>
	</div>	
 
</template>

<script >
export default {
	props: ['cartfoods','totalprice','numbers','goorderzt'],
  data () {
    return {     
     //numbers:0,     
     cartlistshow:false,
     //totalprice:0
    }  
  },
  mounted(){ 	
 
	 },
  methods: {
		listshow: function (numbers){
			if(numbers>0){
				this.cartlistshow=!this.cartlistshow;
			}
//			numbers>0?this.cartlistshow=!this.cartlistshow:'';
			 this.$emit('listshow',this.cartlistshow);
		},
		subtract: function (cartfood){			
			 this.$emit('subtract',cartfood);
		},
		add: function (cartfood){
			 this.$emit('add',cartfood);
		},		
		remove:function(){
//			sessionStorage.removeItem('cartfoods');
//			sessionStorage.removeItem('totalprice');
//			sessionStorage.removeItem('numbers');
		}
				
	}  
}
</script>
<style scoped src="../assets/css/buycart.css"></style>
